<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 * Summary : 博客文章评论表
 * Author : Steven Wang
 * Date : 21 Oct,2011
 */
class Comments extends CI_Model
{
	protected $_name = "blog_comment";

	/*
	 summary : 根据文章编号获取该文章的评论
	 author : Steven Wang
	 date : 21 Oct,2011

	 params :
	 <int>$articleId : 文章编号
	 return :
	 array
	 	[0] => array
	 			[Blog_Comment_ID] => ...
	 			[...] => ...
	*/
	function getCommentsByArticleID($articleId)
	{
		$query = $this->db
					->select(array(
						"Blog_Comment_ID",
						"Blog_Comment_ParentID",
						"Blog_Comment_Author",
						"MD5(Blog_Comment_Email) AS Blog_Comment_Email",
						"DATE_FORMAT(Blog_Comment_PublishTime,'%d %b %Y, %H:%i:%s') AS Blog_Comment_PublishTime",
						"Blog_Comment_Content"))
					->from($this->_name)
					->where("Blog_Article_ID",$articleId)
					->order_by("Blog_Comment_PublishTime","ASC")
					->get();
		$result = $query->result_array();
		return $result;
	}
}

?>